package com.lihao.sam.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lihao.sam.dao.ScoreStatisticsDao;
import com.lihao.sam.entity.ScoreSet;
import com.lihao.sam.entity.ScoreStatistics;
import com.lihao.sam.service.intf.ScoreStatisticsService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 赵申奥
 * @Description:
 */
@Service
public class ScoreStatisticsImpl implements ScoreStatisticsService {
    @Resource
    private ScoreStatisticsDao dao;
    @Override
    public R add(ScoreStatistics scoreStatistics) {
        if(dao.add(scoreStatistics)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R update(ScoreStatistics scoreStatistics) {
        if(dao.update(scoreStatistics)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R delete(int id) {
        if(dao.delete(id)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public PageVo queryPage(String sno, String name, String address, int page, int limit) {
        PageHelper.startPage(page, limit);
        PageInfo<ScoreStatistics> pageInfo=new PageInfo<>(dao.selectAll(sno, name, address));
        return PageVo.ok(pageInfo.getTotal(),pageInfo.getList());
    }
}
